package com.ssyc.student.adapter;

import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import com.ssyc.common.adapter.CommonAdapter;
import com.ssyc.common.adapter.ViewHolder;
import com.ssyc.student.R;
import com.ssyc.student.bean.StAnswerInfo;

import java.util.List;

/**
 * 学生端--选择题列表展示的适配器
 * Created by Administrator on 2018/5/10 0010.
 */

public class StErrorAnswerLvAdapter extends CommonAdapter<StAnswerInfo> {

    private Context context;
    private String explain;

    public StErrorAnswerLvAdapter(Context context, List<StAnswerInfo> datas, int layoutId,String explain) {
        super(context, datas,layoutId);
        this.context = context;
        this.explain = explain;
    }

    @Override
    public void convert(ViewHolder holder, StAnswerInfo stAnswerInfo) {
        //答案序号对应A B C D E 等等
        TextView tvAnswerFlag = holder.getView(R.id.tv_answer_flag);
        tvAnswerFlag.setText(stAnswerInfo.answerFlag);

        //答案的内容
        TextView tvAnswerContent = holder.getView(R.id.tv_answer_content);
        tvAnswerContent.setText(stAnswerInfo.answerContent);
        if (stAnswerInfo.isSelect) {
            //当前答案被选中
            tvAnswerFlag.setTextColor(context.getResources().getColor(R.color.white));
            tvAnswerFlag.setBackgroundResource(R.drawable.st_answer_false_bg);
        } else {
            //当前答案未被选中
            tvAnswerFlag.setTextColor(context.getResources().getColor(R.color.st_answer_normal));
            tvAnswerFlag.setBackgroundResource(R.drawable.st_answer_normal_bg);
        }
        //正确作答
        if(stAnswerInfo.answerContent.equals(explain)){
            tvAnswerFlag.setTextColor(context.getResources().getColor(R.color.white));
            tvAnswerFlag.setBackgroundResource(R.drawable.st_answer_ture_bg);
        }

        Log.e("test","我的答案："+explain+"选项内容："+stAnswerInfo.answerContent);
    }
}
